// Xampler, a MIDI-driven sampler
// Copyright (C) 2006 Nick Thomas
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA

#include "Instrument.hpp"
#include <sstream>
using namespace xampler;

Instrument::Instrument()
{
    for (int i = 0; i < MAX_SAMPLES; i++) {
        m_samples[i] = 0;
    }
}

Instrument::~Instrument()
{
    for (int i = 0; i < MAX_SAMPLES; i++) {
        if (m_samples[i]) {
            delete m_samples[i];
        }
    }
}

void Instrument::set_sample(int number, Sample *sample)
{
    remove_sample(number);
    m_samples[number] = sample;
}

bool Instrument::remove_sample(int number)
{
    if (m_samples[number]) {
        delete m_samples[number];
        return true;
    } else {
        return false;
    }
}

void Instrument::clear()
{
    for (int i = 0; i < MAX_SAMPLES; i++) {
        remove_sample(i);
    }
}
